package com.hsy.linemoney.modules.exchange;

import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.deparse.dpframe.tools.utils.DPLogUtil;
import com.hsy.linemoney.R;
import com.hsy.linemoney.apiservice.LineMoneyContext;
import com.hsy.linemoney.modules.common.CommonBaseActivityWithSimpleActionBar;
import com.hsy.linemoney.utils.CommonUtils;

/**
 * Created by Administrator on 2017/1/13.
 */

public class ExchangeVerifiedFailActivity extends CommonBaseActivityWithSimpleActionBar {
    private WebView webView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_team);
        setTitle(R.string.title_my_account);
        CommonUtils.showProgressDialog(this);
        webView = (WebView) findViewById(R.id.web_view);
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress >= 100) {
                    CommonUtils.hideProgressDialog();
//                    showToast("请在此处登录一次");
                }
            }
        });
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                DPLogUtil.d("url=" + url);
                return true;
            }
        });
//        settings.setAppCacheEnabled(true);
        webView.loadUrl(LineMoneyContext.getServer() + "group/control_panel/manage?p_p_id=2");
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (KeyEvent.KEYCODE_BACK == event.getKeyCode() && KeyEvent.ACTION_UP == event.getAction() && webView.canGoBack()) {
            webView.goBack();
            return true;
        }
        return super.dispatchKeyEvent(event);
    }
}
